package com.xmxsuperstar.http;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HttpHeaders implements Serializable {
	private static final long serialVersionUID = 1L;

	private Map<String, List<String>> innerStore = new HashMap<String, List<String>>();

	public void add(String heaerName, String headerValue) {

		List<String> valueList = innerStore.get(heaerName);
		if (valueList == null) {
			valueList = new ArrayList<String>();
		}

		valueList.add(headerValue);

		innerStore.put(heaerName, valueList);
	}

	public void addAll(HttpQueryParams otherParams) {
		for (String key : otherParams.getAllKeys()) {
			for (String value : otherParams.get(key)) {
				this.add(key, value);
			}
		}
	}

	public List<String> get(String headerName) {
		return innerStore.get(headerName) == null ? new ArrayList<String>()
				: innerStore.get(headerName);
	}

	public List<String> fetchAllHeaderNames() {
		List<String> keysList = new ArrayList<String>();
		for (String key : innerStore.keySet()) {
			keysList.add(key);
		}
		return keysList;
	}

	public Map<String, List<String>> getAllHeaders() {
		return this.innerStore;
	}

}
